package com.hzit.task.job;

import com.pay.center.common.resp.Response;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.web.client.RestTemplate;

import java.util.List;

import static com.sun.xml.internal.ws.api.message.Packet.Status.Response;

/**
 * 支付宝单笔查询任务
 * 通过定时触发：调用支付宝交易查询接口。更新流水状态
 *
 *
 */
@Component
public class AlipaySingleQueryJob {

    @Autowired
    private RestTemplate restTemplate;


    //1.任务重跑
    //2.任务暂停
    //3.任务监控
    // 调度任务平台： xxl-job
//    @Scheduled(cron = "0/3 * * * * ?")
    @XxlJob("alipaySingleQueryJob")
    public ReturnT<String> execute(String param){
        System.out.println("------支付宝单笔查询任务-----------");

        //触发交易查询任务。
        String url = "http://127.0.0.1:8822/paymenet/queryList";
        try {
            Response response = restTemplate.postForObject(url,null, com.pay.center.common.resp.Response.class);
            return ReturnT.SUCCESS;
        }catch (Exception e){
            return ReturnT.FAIL;

        }
    }
}
